/**
 * Created by zy on 2016/7/7.
 * 缺陷维修管理 - 地图
 */


;(function($, window, document, undefined){

    /**
     * gis地图参数
     */
    var gisJsonArr = [
        {
            'typeName': 'pipeLineId',
            'gisIdArray': []
        },
        {
            'typeName': 'inspDefect',
            'gisIdArray': []
        },
        {
            'typeName': 'valveRoomPoint',
            'gisIdArray': []
        }
    ];

    /**
     * dyMap 地图对象, currentMap 当前地图对象
     */
    var dyMapIfarme, dyMap, curent_map;
    dyMapIfarme = $('#JQ_dyMap').get(0);
    dyMapIfarme.onload = function(){
        // 地图加载完毕
        dyMap = dyMapIfarme.contentWindow.queryMutiLayers;
        curent_map = dyMapIfarme.contentWindow.basePipeMap.currentMap;

        // 自动查询
        var repairTaskId = $('#JQ_repairTaskId').val();
        var pipeLineId = $('#JQ_pipeLineId').val();
        if(repairTaskId){
            DyyBase.ajax(DyyBase.url_repair_location_map_task(),{repairTaskIds:repairTaskId,pipeLineId:pipeLineId},function(dataset){
                var defectInfoList = dataset.result.defectInfoList;
                gisJsonArr[0].gisIdArray = dataset.result.pipeLineGisidList;
                gisJsonArr[2].gisIdArray = dataset.result.valveRoomGisIdList;
                if(defectInfoList.length > 0){
                    for(var i = 0, len = defectInfoList.length; i < len; i++){
                        gisJsonArr[1].gisIdArray.push(defectInfoList[i].gisId);
                    }
                }
                dyMap(curent_map,gisJsonArr);
            });
        }
    };

    /**
     * 返回列表
     */
    $('#JQ_task_map_goback').click(function(){
        DyyBase.goToPage(DyyBase.root_path + '/pbf/RepairTask/init.html');
    });
})(jQuery, window, document);